<?php
/* @var $this TagController */
/* @var $model Tag */

$this->breadcrumbs=array(
	'Tags'=>array('index'),
	'Manage',
);
?>

<div class="page-header">
	<div class="page-title"><h3><?php echo Yii::t('app', 'Page setup') ?></h3></div>
</div>

<div class="row-fluid">
<?php echo CHtml::dropdownList('page', $model->id, $model->getListData(), array('id'=>'pageSelect', 'empty'=>Yii::t('app', '--Add page--'))); ?>
</div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'edit-form',
	// 'htmlOptions' => array('class'=>'form-horizontal')
)); ?>

<div class="control-group">
	<div class="">
		<?php echo $form->textField($model,'name',array('class'=>'span6','maxlength'=>200, 'placeHolder'=>Yii::t('app', 'Page name'))); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>
</div>

<?php if (!$model->isNewRecord): ?>
<div class="control-group">
	<p>Ulr: <a href="<?php echo $model->getUrl() ?>" target="_blank"><?php echo $model->getUrl() ?></a></p>
</div>
<?php endif ?>
<div class="control-group">
	<div class="">
		<?php $this->widget('ext.ckeditor.CKEditorWidget',array(
			"model"=>$model,
			"attribute"=>'content',
			"config" => array(
				"height"=>"300px",
				"width"=>"800px",
				"toolbar"=>"Basic",
			),
		)); ?>
		<?php echo $form->error($model,'content'); ?>
	</div>
</div>

<div class="control-group">
	<button type="submit" class="btn btn-primary"><?php echo Yii::t('app', 'Save') ?></button>
	<?php if(!$model->isNewRecord): ?>
	<a class="btn btn-danger" id="btn_delete" href="<?php echo $this->createUrl('delete', array('id'=>$model->id))?>"  data-loading-text="<?php echo Yii::t('app', 'Delete') ?>..."><?php echo Yii::t('app', 'Delete') ?></a>
	<?php endif ?>
</div>
<?php $this->endWidget(); ?>

<script>
$('#pageSelect').change(function (){
	window.location = '<?php echo $this->createUrl('index')?>/id/'+this.value;
});
</script>